﻿#ifndef DEVICESTATUS_H
#define DEVICESTATUS_H

#include <QObject>
#include <QSerialPort>
#include <QMap>
#include <QSerialPortInfo>
#include <QTimer>
#include "../commons/comalgor.h"

/*
 * 设备状态
*/
class DeviceStatus : public QObject
{
    Q_OBJECT
public:
    explicit DeviceStatus(QObject *parent = nullptr);
    virtual ~DeviceStatus();

    static DeviceStatus * gestance();


    void initComSeriel();

    void setIsCleans(bool * isCleans);
    void setIsCleanPause(bool * isCleanPause);
    void setIsOut(bool * isOut);

signals:
    void sigPinsInfor(QMap<int ,int> pinInfors);
    void sigElectric(int userPin , int realPin , int status); // 0 zheng chang 1 duanlu  2 chaoguodianliu
    void sigElectricHandl();
    void sigWarterHandl();

public slots:
    void onDataReceived();

private:

    static DeviceStatus * m_deviceStatus;
    QSerialPort * m_serial;

    ComAlgor * m_comAlgor;
    QByteArray m_currentData ;



public:
    QMap<int ,int> mBuffStatus;//输入引脚状态
    QMap<int ,int> mBuffHeight;//输出物料高度
    QMap<int ,int> mBuffCricle;//电流
    QMap<int ,int> mBuffrempute;//温度
    bool * m_isCleans;
    bool * m_isCleanPause;
    bool * m_isOut;


};

#endif // DEVICESTATUS_H
